import manifest from "@/manifest.json"

// #ifdef H5
// 微信公众号授权登录
export function wxPublicAuth(params) {
  // snsapi_base 静默 snsapi_userinfo 手动
  let scope = params?.scope || "snsapi_base"
  let appid = params?.appid || manifest["mp-weixin"].appid
  let redirectUrl = encodeURIComponent(window.location.href)
  window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUrl}&response_type=code&scope=${scope}&state=STATE#wechat_redirect`
}
// #endif
